- Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathsource.cpp
46 lines (40 loc) · 1.38 KB
/
source.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#using <System.Windows.Forms.dll>
#using <System.dll>
#using <System.Data.dll>
#using <System.Drawing.dll>
usingnamespaceSystem;
usingnamespaceSystem::Data;
usingnamespaceSystem::ComponentModel;
usingnamespaceSystem::Windows::Forms;
usingnamespaceSystem::Drawing;
public ref classForm1: publicForm
{
protected:
TextBox^ textBox1;
TextBox^ pictureBox1;
System::Windows::Forms::ContextMenu^ contextMenu1;
// <Snippet1>
private:
voidMyPopupEventHandler( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
// Define the MenuItem objects to display for the TextBox.
MenuItem^ menuItem1 = gcnew MenuItem( "&Copy" );
MenuItem^ menuItem2 = gcnew MenuItem( "&Find and Replace" );
// Define the MenuItem object to display for the PictureBox.
MenuItem^ menuItem3 = gcnew MenuItem( "C&hange Picture" );
// Clear all previously added MenuItems.
contextMenu1->MenuItems->Clear();
if ( contextMenu1->SourceControl == textBox1 )
{
// Add MenuItems to display for the TextBox.
contextMenu1->MenuItems->Add( menuItem1 );
contextMenu1->MenuItems->Add( menuItem2 );
}
elseif ( contextMenu1->SourceControl == pictureBox1 )
{
// Add the MenuItem to display for the PictureBox.
contextMenu1->MenuItems->Add( menuItem3 );
}
}
// </Snippet1>
};